package br.com.alinesoftware.app.entity;


import java.io.Serializable;
import com.powerlogic.jcompany.domain.validation.PlcUnifiedValidation;
import com.powerlogic.jcompany.domain.validation.PlcValCpf;

import javax.persistence.ManyToOne;
import javax.persistence.Column;
import javax.validation.constraints.NotNull;
import javax.persistence.Id;
import javax.persistence.GenerationType;
import javax.persistence.MappedSuperclass;
import javax.persistence.JoinColumn;
import javax.persistence.FetchType;
import com.powerlogic.jcompany.config.domain.PlcReference;
import org.hibernate.annotations.ForeignKey;
import javax.persistence.GeneratedValue;

@MappedSuperclass
@PlcUnifiedValidation
public abstract class ClienteProprietario  implements Serializable {

	private static final long serialVersionUID = -3675098990067865031L;

	@Id 
 	@GeneratedValue(strategy=GenerationType.AUTO, generator = "SE_CLIENTE_PROPRIET")
	@Column(nullable=false,length=5)
	private Long id;
	
	@ManyToOne (targetEntity = ProprietarioEntity.class, fetch = FetchType.LAZY)
	@ForeignKey(name="FK_ESTABPROPR_PROPRIET")
	@NotNull
	@JoinColumn
	private Proprietario proprietario;
	
	@ManyToOne (targetEntity = ClienteEntity.class, fetch = FetchType.LAZY)
	@ForeignKey(name="FK_CLIENTEPROPR_CLIENTE")
	@NotNull
	@JoinColumn
	private Cliente cliente;
	
	@PlcValCpf
	@NotNull
	@Column(length=5)
	@PlcReference(testDuplicity=true)
	private Long cpfProprietario;
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id=id;
	}

	public Proprietario getProprietario() {
		return proprietario;
	}

	public void setProprietario(Proprietario proprietario) {
		this.proprietario=proprietario;
	}

	public Long getCpfProprietario() {
		return cpfProprietario;
	}

	public void setCpfProprietario(Long cpfProprietario) {
		this.cpfProprietario=cpfProprietario;
	}

	public Cliente getCliente() {
		return cliente;
	}

	public void setCliente(Cliente cliente) {
		this.cliente = cliente;
	}
}
